<!--Author: @ngel Sullon Macalupu-->
<?
require_once '../../Include.php';
require_once '../../WEB_INF/SubmitConsulting/LiveScrum/ModScrum/Data/ProductoData.php';
require_once '../../WEB_INF/SubmitConsulting/LiveScrum/ModScrum/Data/Entity/Producto.php';
require_once '../../WEB_INF/SubmitConsulting/LiveScrum/ModScrum/Data/ItemData.php';
require_once '../../WEB_INF/SubmitConsulting/LiveScrum/ModScrum/Data/Entity/Item.php';
require_once '../../WEB_INF/SubmitConsulting/LiveScrum/ModScrum/Data/Enum/ItemTipo.php';
require_once '../../WEB_INF/SubmitConsulting/LiveScrum/ModScrum/Data/Enum/TaskEstado.php';
require_once '../../WEB_INF/SubmitConsulting/LiveScrum/ModScrum/Data/Enum/TaskFlujo.php';
require_once '../../WEB_INF/SubmitConsulting/LiveScrum/ModScrum/Data/Enum/ImpedimentEstado.php';
require_once '../../WEB_INF/SubmitConsulting/LiveScrum/ModScrum/Data/Enum/BugEstado.php';
require_once '../../WEB_INF/SubmitConsulting/LiveScrum/ModScrum/Data/Enum/BugGravedad.php';

require_once '../../WEB_INF/SubmitConsulting/LiveScrum/ModScrum/Data/IteracionData.php';
require_once '../../WEB_INF/SubmitConsulting/LiveScrum/ModScrum/Data/Entity/Iteracion.php';

require_once '../../WEB_INF/SubmitConsulting/LiveScrum/ModConfig/Data/UsuarioData.php';
require_once '../../WEB_INF/SubmitConsulting/LiveScrum/ModConfig/Data/Entity/Usuario.php';
require_once '../../WEB_INF/SubmitConsulting/LiveScrum/ModScrum/Data/Entity/Proyecto.php';
?>
<html>
    <head>
        <link type="text/css" rel="STYLESHEET" href="../../Recurso/Style/App.css">
        <script type="text/javascript" src="../../Recurso/Script/app.util.js" ></script>
        <script type="text/javascript" src="../../Recurso/Script/jquery.js" ></script>

        <script type="text/javascript"
        src="../../Recurso/Script/jquery.datepick.js"></script>
        <script type="text/javascript"
        src="../../Recurso/Script/jquery.datepick-es-PE.js"></script>
        <link rel=stylesheet type="text/css"
              href="../../Recurso/Script/jquery.datepick.css">
        <script type="text/javascript">
            $(function() {
                //$('#criterioAcepta').datepick();
            });
        </script>

        <script type='text/javascript' language='JavaScript'><!--
            function cancelar(){ document.fm2.submit(); }
            function enviar(){
                if( document.fm.titulo.value==''){
                    alert('Complete titulo');
                    document.fm.rutaSprints.select(); //focus()
                    return false;
                }
                if(confirm('Esta seguro enviar?')) return true;
                else return false;
            }

            function eliminarConfirm() {
                if(confirm('Eliminar por completo?')){
                    document.fm2.action='ItemSave.php';
                    document.fm2.go.value='Eliminar';
                    document.fm2.submit();
                }
                else return false;
            }
            function sf(){ document.fm.titulo.focus(); }
            // --></script>
    </head>
<?
$go = trim($_POST['go']) ? trim($_POST['go']) : '';
$itemTipo = trim($_POST['itemTipo']) ? trim($_POST['itemTipo']) : '';

$productoId = trim($_POST['productoId']) ? trim($_POST['productoId']) : '';
$itemId = trim($_POST['itemId']) ? trim($_POST['itemId']) : '';
$d = new Item();
$d->setItemTipo($itemTipo);
$tranI = new IteracionData();
$rowI = $tranI->listByFilter($_SESSION['proyectoId']);
$tranR = new UsuarioData();
$rowR = $tranR->listByFilter("");

$tran = new ProductoData();
$producto = $tran->findByPk($productoId);

if ($go == 'Editar') {
    $tran = new ItemData();
    $d = $tran->findByPk($itemId);
}
?>
    <body onload="sf()">
<? require_once '../../Menu/Rol1/open.php'; ?>
        <? $itemTab = "2";
        require_once '../../Menu/Rol1/menuSection.php'; ?>
        <div class="main">
            <div class="AlignLeft">
                <? $link = $d->getItemTipo();
                require_once 'menuPlan.php'; ?>
            </div>

            <div class='form'>
                <table class='TableForm' align='center'>
                    <!-- head -->
                    <tr class=TableFormTitle>
                        <td colspan='3'>Formulario: Registro elemento de trabajo tipo <?=$d->getItemTipo()?>
                        </td>
                    </tr>
                    <tr class='legendIndication'>
                        <td colspan='3'><?= $go ?> Item, por
				favor complete los datos con *. <br>Luego precione el
				bot&oacute;n <b><?= $go ?> </b> para guardar la informaci&oacute;n
				ingresada.</td>
                    </tr>
			<tr>
				<td rowspan='2' class='img' width='130' align='center'><//img
					src='../../Recurso/Foto/' width='120'
					height='140'>
				</td>
				<td rowspan='2' style='width: 5px; vertical-align: top;'
					class='fonc'></td>
				<td colspan='1'></td>
			</tr>
                            
		<form action='ItemSave.php' method='post' name='fm'
			onsubmit='return enviar()'>
			<input type='hidden' name='go' value='<?= $go ?>'>
			<input type='hidden' name='itemId' value='<?= $itemId ?>'>
			<input type='hidden' name='productoId' value='<?= $productoId ?>'>
                        <input type='hidden' name='itemTipo' value='<?= $d->getItemTipo() ?>'>
                     <tr>
                         <td valign='top' colspan="1">
                        <table>
			<tr>
                            <td valign='top' colspan="2">

						<table>
							<tr>
                                                            <td colspan="2"></td>
							</tr>
							<tr>
								<td>Producto:</td>
                                                                <td><b><?=$producto->getTitulo()?></b></td>
							</tr>
							<tr>
								<td>Realizar para:</td>
								<td><b><?=$producto->getIteracionRef()->getRutaSprint()?></b></td>
							</tr>
							<tr>
								<td>Work Item Tipo:</td>
                                                                <td>
                                                                    <select disabled>
										<?
										foreach (ItemTipo::$enum as $key => $value)
										{
											echo '<option value='.$key.''; if($key==$d->getItemTipo()) echo ' selected';
											echo '>';
											echo $value.' ('. $key .')';
											echo '</option>';
										}
										?>
								</select>
								</td>
							</tr>
							<tr>
								<td>Titulo: *</td>
								<td><input type='text' class='textEntry' name='titulo'
                                                                           value='<?=$d->getTitulo()?>' ></td>
							</tr>

							<tr>
								<td>Prioridad: *</td>
								<td>
                                                                    <select name="prioridad">
                                                                        <option value="0" <?if($d->getPrioridad()==0) echo ' selected';?>></option>
                                                                        <option value="1" <?if($d->getPrioridad()==1) echo ' selected';?>>1-Alta</option>
                                                                        <option value="2" <?if($d->getPrioridad()==2) echo ' selected';?>>2-Media</option>
                                                                        <option value="3" <?if($d->getPrioridad()==3) echo ' selected';?>>3-Baja</option>
                                                                    </select></td>
							</tr>
							<tr>
								<td>Esfuerzo: *</td>
								<td><input type='text' class='numberEntry' name='esfuerzo'
									value='<?=$d->getEsfuerzo()?>' size='4'></td>
							</tr>
                                                        <?if ($d->getItemTipo()== ItemTipo::$Task ) {?>
							<tr>
								<td>TaskFlujo:</td>
								<td><select name="taskFlujo">
                                                                        <option value=""></option>
										<?
										foreach (TaskFlujo::$enum as $key => $value)
										{
											echo '<option value='.$key.''; if($key==$d->getTaskFlujo()) echo ' selected';
											echo '>';
											echo $value.' ('. $key .')';
											echo '</option>';
										}
										?>
								</select>
								</td>
                                                                </tr>
                                                          <?} ?>
                                                          <?if ($d->getItemTipo()== ItemTipo::$Bug) {?>
							<tr>
								<td>BugGravedad:</td>
								<td>
                                                                    <select name="bugGravedad">
                                                                        <option value=""></option>
										<?
										foreach (BugGravedad::$enum as $key => $value)
										{
											echo '<option value='.$key.''; if($key==$d->getBugGravedad()) echo ' selected';
											echo '>';
											echo $value.' ('. $key .')';
											echo '</option>';
										}
										?>
								</select>
                                                                </td>
							</tr>
                                                        <?} ?>
						</table>
				</td>
			</tr>
			<tr>
                            <td valign='top' colspan="2">
					<fieldset>
						<legend>
							Estado
						</legend>
<!--                                            Instrucciones-->
						<table>
							<tr>
								<td>Asignado A:</td>
								<td><select name="asignadoA">
								<option value=""></option>
										<?
										for( $i=0; $i < count($rowR); $i++ )
										{
											echo '<option value='.$rowR[$i]->getUsuarioId().''; if($rowR[$i]->getUsuarioId()==$d->getAsignadoARef()->getUsuarioId()) echo ' selected';
											echo '>';
											echo $rowR[$i]->getNombres().' ('. $rowR[$i]->getUsuarioId() .')';
											echo '</option>';
										}
									?>
								</select>
								</td>
							</tr>
							<tr>
								<td>Estado:</td>
								<td><select name="estado">

										<?
                                                                                if ($d->getItemTipo()== ItemTipo::$Task ) 
										foreach (TaskEstado::$enum as $key => $value)
										{
											echo '<option value='.$key.''; if($key==$d->getEstado()) echo ' selected';
											echo '>';
											echo $value.' ('. $key .')';
											echo '</option>';
										}


                                                                                if ($d->getItemTipo()== ItemTipo::$Impediment ) 
										foreach (ImpedimentEstado::$enum as $key => $value)
										{
											echo '<option value='.$key.''; if($key==$d->getEstado()) echo ' selected';
											echo '>';
											echo $value.' ('. $key .')';
											echo '</option>';
										}
                                                                                
                                                                                if ($d->getItemTipo()== ItemTipo::$Bug ) 
										foreach (BugEstado::$enum as $key => $value)
										{
											echo '<option value='.$key.''; if($key==$d->getEstado()) echo ' selected';
											echo '>';
											echo $value.' ('. $key .')';
											echo '</option>';
										}
                                                                                
										?>
								</select> 
								</td>
							</tr>
                                                        <?if ($d->getItemTipo()== ItemTipo::$Task ) {?>
							<tr>
								<td>TaskBloqueado?:</td>
								<td>
                                                                    <select name="taskBloqueado">
                                                                        <option value=""></option>
                                                                        <option value="Si" <?if($d->getTaskBloqueado()=='Si') echo ' selected';?>>Si</option>
                                                                    </select>
							</tr>
                                                        <?} ?>

                                             </table>
                                             </fieldset>
					</td>
                            </tr>
                             <tr>
                                 <td valign='top'>
					<fieldset>
						<legend>
							Descripcion
						</legend>

								<textarea name="descripcion" rows="12" cols="30" class='textareaEntry'><?=$d->getDescripcion()?></textarea>
                                            </fieldset>

				</td>
                                 <td valign='top'>
                                     <?if ($d->getItemTipo()== ItemTipo::$Impediment ) {?>
					<fieldset>
						<legend>
							ImpeResolucion
						</legend>

								<textarea name="impeResolucion" rows="5" cols="30" class='textareaEntry'><?=$d->getImpeResolucion()?></textarea>
                                            </fieldset>
                                     <?} ?>
                                     <?if ($d->getItemTipo()== ItemTipo::$Bug ) {?>
					<fieldset>
						<legend>
							BugAceptacion
						</legend>

								<textarea name="bugAceptacion" rows="5" cols="30" class='textareaEntry'><?=$d->getBugAceptacion()?></textarea>
                                            </fieldset>
                                     <?} ?>


					<fieldset>
						<legend>
							Historia
						</legend>

                                            <textarea name="historia" rows="5" cols="30" class='textareaEntry'><?=$d->getHistoria()?></textarea>
                                            </fieldset>
				</td>
                            </tr>
                        </table>

                        </td>
                    </tr>

                    <TR class=TableFormFooter>
                         <TD colSpan=3 align="right">&nbsp;
                                    <input type='submit' class='Btn'
					value='<?= $go ?>'> <?php if( $go=='Editar' ) echo "<input type='button' class='Btn' value='Eliminar' onclick='eliminarConfirm();'>" ?>
					<input type='button' class='Btn' value='Cancelar'
					onclick='cancelar()'>

                    </TD></TR>
		</form>



                </table>
            </div>
        </div>
<? require_once '../../Menu/Rol1/close.php'; ?>
                        </body>
                    </html>

<form action='ItemMain.php' method='post' name='fm2'>
        <input type='hidden' name='link' value='<?= $d->getItemTipo() ?>'>
        <input type='hidden' name='itemTipo' value='<?= $d->getItemTipo() ?>'>
        <input type='hidden' name='itemId' value='<?= $itemId ?>'>
    <input   type='hidden' name='go' value=''>
</form>


